//
//  main.m
//  03-HomeWork
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 daming. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BookManager.h"
#import "Book.h"
int main(int argc, const char * argv[]) {
//   1.截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
    
    NSString *urlString = @"20|https://www.baidu.com";
    NSArray *urlArray = [urlString componentsSeparatedByString:@"|"];
    NSLog(@"urlArray = %@", urlArray);
//   2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
    
    int a = 10;
    float b = 0.2;
    double c = 0.5;
    BOOL d = NO;
    NSString *intStr = [NSString stringWithFormat:@"%d", a];
    NSString *floatStr = [NSString stringWithFormat:@"%f", b];
    NSString *doubleStr = [NSString stringWithFormat:@"%f", c];
    NSString *boolStr = [NSString stringWithFormat:@"%d", d];
    NSMutableArray *mutableArr = [NSMutableArray arrayWithObjects:intStr, floatStr, doubleStr, boolStr, nil];
    NSLog(@"%@", mutableArr);
//   3.实现图书管理系统(BookManager类)：
//    使用数组管理所有书籍(Book类)。
//    BookManager类属性数组可以添加、删除。
//    可以从数组根据书名查找书籍，并修改书籍的价格。
//    展示所有书籍清单（书名）

#pragma mark - 创建书籍对象
    Book *book1 = [[Book alloc]initWithBookName:@"西游记" bookPrice:20];
    Book *book2 = [[Book alloc]initWithBookName:@"三国演义" bookPrice:30];
    Book *book3 = [[Book alloc]initWithBookName:@"红楼梦" bookPrice:40];
    Book *book4 = [[Book alloc]initWithBookName:@"水浒传" bookPrice:50];
#pragma mark - 创建管理系统
    BookManager *bookMuArray = [BookManager bookManagerWithBookArray];
#pragma mark - 将书籍对象添加到管理系统
    bookMuArray.bookArray = [NSMutableArray arrayWithObjects:book1, book2, book3, book4, nil];
#pragma mark - 添加一个书籍
    [bookMuArray addBookOfBookName:@"iOS" bookPrice:100];
#pragma mark - 删除一个书籍
    [bookMuArray deleteBookOfBookName:@"西游记"];
#pragma mark - 修改价格
    [bookMuArray searchAndchangeOfBookName:@"三国演义" bookPrice:25];
#pragma mark - 输出书籍的名称和价格
    [bookMuArray showAllBookName];
    return 0;
}
